/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.suarte.core.service.impl;

import com.suarte.core.*;
import com.suarte.core.dao.PaymentDao;
import com.suarte.core.service.PaymentManager;
import com.suarte.core.service.PaymentStatus;
import org.appfuse.service.impl.GenericManagerImpl;

import java.util.List;
import java.util.Date;

/**
 * @date   Feb 16, 2011
 * @author Gcastillo
 */
public class PaymentManagerImpl extends GenericManagerImpl<Payment, Long> implements PaymentManager {
    PaymentDao paymentDao;

    public PaymentManagerImpl(PaymentDao paymentDao) {
        super(paymentDao);
        this.paymentDao = paymentDao;
    }

    public List<Payment> findByDescription(String description) {
        return paymentDao.findByDescription(description);
    }

    public void store(Payment object) {
        paymentDao.store(object);
    }

    @Override
    public Payment get(Long id) {
        return paymentDao.get(id);
    }

    public void deleteDetails(List<InvoicePayment> args) {
        paymentDao.deleteDetails(args);
    }

    public void approve(Payment object) {
        object.setStatus(PaymentStatus.APLICADO);
        paymentDao.save(object);
    }

    public List<Payment> findPayments(Long id, String description, Date date, Company company, Contact contact, PaymentStatus status) {
        return paymentDao.findPayments(id, description, date, company, contact, status);
    }
}